from app.autojob.models import InitTaskList
from app.autojob.utls import dict_handle


def init_task_columns(tab):
    """初始化任务列表表头"""
    columns = [
        {
            "label": "资产SN",
            "prop": "systemSN",
            "minWidth": 150,
            "fixed": "left",
        },
        {
            "label": "工单号",
            "prop": "ticketSn",
            "minWidth": 150,
        },
        {
            "label": "所在机房",
            "prop": "idc",
            "minWidth": 120,
        },
        {
            "label": "业务IP",
            "prop": "businessIp",
            "minWidth": 120,
        },
        {
            "label": "业务掩码",
            "prop": "netmask",
            "minWidth": 90,
        },
        {
            "label": "业务网关",
            "prop": "gateway",
            "minWidth": 120,
        },
        {
            "label": "状态",
            "prop": "status",
            "minWidth": 120,
            "fixed": "right",
        }
    ]
    form = [
        {
            "label": "资产SN",
            "prop": "systemSN",
            "type": "input",
            "bind": {
                "placeholder": "请输入资产SN"
            }
        },
        {
            "label": "工单号",
            "prop": "ticketSn",
            "type": "input",
            "bind": {
                "placeholder": "请输入工单号"
            }
        },
        {
            "label": "业务IP",
            "prop": "businessIp",
            "type": "input",
            "bind": {
                "placeholder": "请输入业务IP"
            }
        },
        {
            "label": "所在机房",
            "prop": "idc",
            "type": "select",
            "viewType": "select",
            "bind": {
                "options": dict_handle(InitTaskList, 'idc', filter_data=None),
                "placeholder": "请选择所在机房"
            }
        },
        # {
        #     "label": "状态",
        #     "prop": "statusList",
        #     "type": "select",
        #     "viewType": "select",
        #     "bind": {
        #         "options": dict_handle(InitTaskList, 'status', filter_data=None),
        #         "placeholder": "请选择状态",
        #         "multiple": True
        #     }
        # }
    ]
    # if tab != 'all':
    #     del form[-1]
    return columns, form


def install_task_columns(tab):
    """装机任务表头"""
    columns = [
        {
            "label": "资产SN",
            "prop": "systemSN",
            "minWidth": 150,
            "fixed": "left",
        },
        {
            "label": "MAC地址",
            "prop": "mac",
            "minWidth": 120
        },
        {
            "label": "工单号",
            "prop": "ticketSn",
            "minWidth": 150,
        },
        {
            "label": "所在机房",
            "prop": "idc",
            "minWidth": 120,
        },
        {
            "label": "DHCP地址",
            "prop": "dhcpIp",
            "minWidth": 120,
        },
        {
            "label": "业务地址",
            "prop": "businessIp",
            "minWidth": 120,
        },
        {
            "label": "业务掩码",
            "prop": "netmask",
            "minWidth": 90,
        },
        {
            "label": "业务网关",
            "prop": "gateway",
            "minWidth": 120,
        },
        {
            "label": "带外地址",
            "prop": "ipmi",
            "minWidth": 120,
        },
        {
            "label": "绑定模式",
            "prop": "bond",
            "minWidth": 100,
        },
        {
            "label": "系统版本",
            "prop": "osVersion",
            "minWidth": 100,
        },
        {
            "label": "状态",
            "prop": "status",
            "minWidth": 120,
            "fixed": "right",
        }
    ]
    form = [
        {
            "label": "资产SN",
            "prop": "systemSN",
            "type": "input",
            "bind": {
                "placeholder": "请输入资产SN"
            }
        },
        {
            "label": "工单号",
            "prop": "ticketSn",
            "type": "input",
            "bind": {
                "placeholder": "请输入工单号"
            }
        },
        {
            "label": "业务IP",
            "prop": "businessIp",
            "type": "input",
            "bind": {
                "placeholder": "请输入业务IP"
            }
        },
        {
            "label": "所在机房",
            "prop": "idc",
            "type": "select",
            "viewType": "select",
            "bind": {
                "options": dict_handle(InitTaskList, 'idc', filter_data=None),
                "placeholder": "请选择所在机房"
            }
        },
        # {
        #     "label": "状态",
        #     "prop": "statusList",
        #     "type": "select",
        #     "viewType": "select",
        #     "bind": {
        #         "options": dict_handle(InitTaskList, 'status', filter_data=None),
        #         "placeholder": "请选择状态",
        #         "multiple": True
        #     }
        # }
    ]
    # if tab != 'all':
    #     del form[-1]
    return columns, form
